package nc.ui.arap.report.asyn;

import nc.bs.framework.common.NCLocator;
import nc.bs.pub.taskcenter.AbstractReportLikeWork;
import nc.itf.uap.pa.IPreAlertConfigService;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pub.pa.TimingSettingVO;
import nc.vo.querytemplate.querytype.QueryTypeInfo;
import nc.vo.uap.scheduler.TimeConst;

public class ReportAsynUtils {
	
	public static void  startTask(QueryTypeInfo typeInfo, AbstractReportLikeWork task) throws BusinessException {
		IPreAlertConfigService alertConfigQueryService = NCLocator.getInstance().lookup(IPreAlertConfigService.class);
		TimingSettingVO settingVO = new TimingSettingVO();
		if (typeInfo.isTaskImmediate()) {
			alertConfigQueryService.startReportLikeWork(task, null);
		} else {
			UFDateTime ufdataTimeVO;
			ufdataTimeVO = typeInfo.getTaskStartTime();
			settingVO.setEffibegindate(ufdataTimeVO.getDate().toString());
			settingVO.setEffibegintime("00:00:00");
			settingVO.setEffienddate(ufdataTimeVO.getDate().toString());
			settingVO.setEffiendtime("23:59:59");
			settingVO.setExecutetime(ufdataTimeVO.getTime());
			settingVO.setFrequencytype(TimeConst.DAY);
			settingVO.setIsruncycledaily(UFBoolean.TRUE);
			settingVO.setEndtime("23:59:59");
			alertConfigQueryService.startReportLikeWork(task, settingVO);
		}
	}

}
